import redis

# 创建 Redis 连接对象
r = redis.Redis(host='localhost', port=6379, db=0)

# 创建管道用于打包多个命令
pipe = r.pipeline()

# 执行多个命令
pipe.get('key1')
pipe.get('key2')

# 执行管道操作
results = pipe.execute()
for result in results:
    if result:
        print(result.decode('utf-8'))